package com.googlecode.dgwt.client.dojo.data.base;

import java.util.Set;

import com.googlecode.dgwt.client.dijit.View;
import com.googlecode.dgwt.client.dojo.data.listener.ModelListener;
import com.googlecode.dgwt.client.dojo.data.listener.StoreListener;
import com.googlecode.dgwt.client.dojo.data.model.StoreColumn;
import com.googlecode.dgwt.client.dojo.data.model.StoreModel;
import com.googlecode.dgwt.client.dojo.exception.ValidationException;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public interface ModeledStore<Item> extends IndexedStore<Item> {

    public Item addNew();
    
    public Item addNew(int rowIndex);
    
    public void refreshColumnValues(int columnIndex);

    public StoreModel<Item,? extends StoreColumn<Item, ?>> getModel();

    public String getDisplayValue(Item item, int columnIndex);
    
    public void setDisplayValue(Item item, int columnIndex, String value) throws ValidationException;
    
    public void setDisplayValues(Item item, String ...columnValues) throws ValidationException;

    public int indexOfDisplayValues(String ...columnValues);
    
    public int indexOfDisplayValues(int startColumnIndex, String ...columnValues);
    
    public Item findByDisplayValues(String ...columnValues);

    public Item findByDisplayValues(int startColumnIndex, String ...columnValues);

    public boolean addListener(StoreListener<Item> listener);
    
    public boolean addListener(ModelListener<Item> listener);

    public Set<ModelListener<Item>> getModelListeners();

    public boolean registerParent(View view);
    
    public boolean unregisterParent(View view);
    
    public boolean hasParent(View view);
    
    public Set<View> getParents();
    
    /**
     * Cria um novo store espelhado no store atual
     * 
     * @param model
     *            um novo model a usar para o novo store
     * @return um store que compartilha os mesmos items e listeners
     */
    public ModeledStore<Item> createMirror(StoreModel<Item,?> model);

}
